package in.choich.transaction.xDatasource;

import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
/**
 * 配置数据源
 * @author kevin_zhu
 *
 */
@Configuration
@EnableConfigurationProperties
@EnableAutoConfiguration
public class XDatasourceConfig {

	
	
	@Bean
    @ConfigurationProperties(prefix = "spring.jta.atomikos.datasource.primary")
	@Primary
    public DataSource primaryDataSource() {
        return new AtomikosDataSourceBean();
    }
	
	@Bean
    @ConfigurationProperties(prefix = "spring.jta.atomikos.datasource.secondary")
    public DataSource secondaryDataSource() {
        return new AtomikosDataSourceBean();
    }
	
}
